********************************************************************************
** Do file: g8_baseline_chars.do
** First started: June 11, 2020 
** Last edited: November 29, 2023

/* Purpose: this do file compares baseline survey variables between groups
Part I: Set Up
Part II: Statistics for Baseline Characteristics table
Part III: T-tests between columns for Baseline Characteristics p-values table
Part IV: Statistics for Baseline Characteristics table, for the endline sample
Part V: T-tests between columns for Baseline Characteristics p-values table, for the endline sample

* ITEM MADE: TABLE A.2
* ITEM MADE: TABLE A.3
* ITEM MADE: TABLE A.4
* ITEM MADE: TABLE A.5
*/

********************************************************************************

clear
clear matrix
clear mata
set maxvar 10000

************
** Part I **
************

* Load the key dataset
use "$merged/key_rep.dta", clear

* Merge baseline data onto the above
merge m:1 hhid using "$bsvy_clean/hhvars_baseline.dta"
assert _merge!=2
drop _merge

* Statistic for income
sum hhincome_other if k_complete_may==1

* Develop filter for sampling framework
g tag = 1 if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_surveyed==1

* Develop a variable that tags those that are in a main treatment group of interest
g maintreat = 1 if treatmenttype_sh=="R T1-L" | treatmenttype_sh == "R T1-U" | treatmenttype_sh == "R T2-U"

* Develop treatment variables
g locked = (treatmenttype_sh=="R T1-L")
g su = (treatmenttype_sh=="R T1-U")
g unlocked = (treatmenttype_sh=="R T2-U")
g control = (treatmenttype_sh=="R C")

* Drop choice treatment
drop if treatmenttype_sh=="R T3"

* Divide the raw income numbers by 3704 to make USD
foreach var of varlist light_spend_year hhincome_other value_hh_assets total_loans {
	replace `var' = `var'/3704
}

* Refusal at baseline
tab ever_refused if tag==1

* Fact for paper: what is income, and what % of this is additional debt for Secured group ($23)
sum hhincome_other if tag==1 // 38/1463 = 3%

*************
** Part II **
*************

***** TABLE A.2 ******

* Baseline characteristics
tabstat accountpercentlocked_may headage headsex headmarried headworks_fam headworks_self headworks_out num_hh n_hhenrolled ///
			light_spend_year hhincome_other value_hh_assets any_loans total_loans ever_refused microfloan if tag==1, by(treatmenttype_sh) statistics(mean sd n)
			
/* Note: overall for income and borrowing:
means:
1463 (school fee loan of 300k (81 USD) is approx 6% of this)
332 (school fee loan of 300k (81 USD) is approx 25% of this)
*/


**************
** Part III **
**************

***** TABLE A.3 ******

** Risk
* Percent of days locked at SMS (%)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Household head
* Age (years)
ttest headage if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Female (proportion)
ttest headsex if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headsex if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Married (proportion)
ttest headmarried if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headmarried if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
		
** Household head occupation (proportion)
* Family business or farm
ttest headworks_fam if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headworks_fam if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Self-employed
ttest headworks_self if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Outside the home
ttest headworks_out if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headworks_out if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_out if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_out if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headworks_out if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headworks_out if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Demographics
* Number of people in household
ttest num_hh if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
		
* Number of children aged 5-20 enrolled in school
ttest n_hhenrolled if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest n_hhenrolled if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Financial information
* Amount spent on lighting, year (USD)
ttest light_spend_year if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Total household income, year (USD)
ttest hhincome_other if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Value of assets (USD)
ttest value_hh_assets if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Borrowing 
* Borrowed in last 12 months (proportion)
ttest any_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Money borrowed in last 12 months (USD)
ttest total_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest total_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest total_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest total_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest total_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest total_loans if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Ever refused for loan in last 12 months (proportion)
ttest ever_refused if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest ever_refused if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest ever_refused if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest ever_refused if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest ever_refused if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest ever_refused if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
	
* Took a microfinance loan in last 12 months (proportion)
ttest microfloan if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest microfloan if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* F test for all variables
g treat_nums = .
replace treat_nums = 0 if treatmenttype_sh=="R C"
replace treat_nums = 1 if treatmenttype_sh=="R T1-L"
replace treat_nums = 2 if treatmenttype_sh=="R T1-U"
replace treat_nums = 3 if treatmenttype_sh=="R T2-U"
manova accountpercentlocked_may headage headsex headmarried headworks_fam headworks_self headworks_out num_hh n_hhenrolled light_spend_year hhincome_other value_hh_assets any_loans total_loans ever_refused microfloan = treat_nums if tag==1



*************
** Part IV **
*************

** Filter down to endline sample **
keep if k_surveyed_end==1


***** TABLE A.4 ******

tabstat accountpercentlocked_may headage headsex headmarried headworks_fam headworks_self headworks_out num_hh n_hhenrolled ///
			light_spend_year hhincome_other value_hh_assets any_loans total_loans ever_refused microfloan if tag==1, by(treatmenttype_sh) statistics(mean sd n)
			
/* Note: overall for income and borrowing:
means:
1437 (so 300k (81 USD) sfl is 6% of this)
325 (so 300k (81 USD) sfl is 25% of this)
*/



************
** Part V **
************

***** TABLE A.5 ******

** Risk
* Percent of days locked at SMS (%)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest accountpercentlocked_may if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Household head
* Age (years)
ttest headage if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headage if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Female (proportion)
ttest headsex if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headsex if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headsex if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Married (proportion)
ttest headmarried if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headmarried if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headmarried if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
		
** Household head occupation (proportion)
* Family business or farm
ttest headworks_fam if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headworks_fam if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_fam if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Self-employed
ttest headworks_self if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_self if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Outside the home
ttest headworks_out if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest headworks_out if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest headworks_out if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest headworks_out if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headworks_out if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest headworks_out if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Demographics
* Number of people in household
ttest num_hh if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest num_hh if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
		
* Number of children aged 5-20 enrolled in school
ttest n_hhenrolled if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest n_hhenrolled if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest n_hhenrolled if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Financial information
* Amount spent on lighting, year (USD)
ttest light_spend_year if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest light_spend_year if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Total household income, year (USD)
ttest hhincome_other if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest hhincome_other if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Value of assets (USD)
ttest value_hh_assets if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest value_hh_assets if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

** Borrowing 
* Borrowed in last 12 months (proportion)
ttest any_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest any_loans if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Money borrowed in last 12 months (USD)
ttest total_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest total_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest total_loans if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest total_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest total_loans if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest total_loans if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* Ever refused for loan in last 12 months (proportion)
ttest ever_refused if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest ever_refused if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest ever_refused if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest ever_refused if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest ever_refused if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest ever_refused if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
display `r(p)'
	
* Took a microfinance loan in last 12 months (proportion)
ttest microfloan if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T1-U") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T1-L" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R T2-U") & tag==1, by(treatmenttype_sh)
display `r(p)'
ttest microfloan if (treatmenttype_sh=="R T1-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)
ttest microfloan if (treatmenttype_sh=="R T2-U" | treatmenttype_sh=="R C") & tag==1, by(treatmenttype_sh)

* F test for all variables
manova accountpercentlocked_may headage headsex headmarried headworks_fam headworks_self headworks_out num_hh n_hhenrolled light_spend_year hhincome_other value_hh_assets any_loans total_loans ever_refused microfloan = treat_nums if tag==1
